<?php
session_start();
require '../nette/Nette/loader.php';
require '../db.php';
require '../localization/lang.php';
require '../core/core.sanitizer.php';
require '../core/core.security.php';
require '../core/core.dfs.php';
require '../visual/visual.dfs.php';
require '../core/core.time.php';
require '../core/core.statistics.php';
$conflicts=0;
$login=new core_security;
if ($login->checklogin()=="OK" AND $_SESSION['role']<=2) {
$loc=new loc;
$statist=new core_statistics($_POST['datefrom'],$_POST['dateto']);
$time=new core_time;

$from=strtotime($_POST['from']);
$to=strtotime($_POST['to']);

/*
$query="select * from attendance where day >= ".$from." AND day <= ".$to." AND uid=".$_POST['uid']." ORDER BY day";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)) {
	$dayrange_from=strtotime(date('m/d/Y',$row['day'])." 00:00:01");
	$dayrange_to=strtotime(date('m/d/Y',$row['day'])." 23:59:59");
	//echo $dayrange_from." ".$dayrange_to;	
	$query2="select sum(duration) as total from userjobs where from_ >= ".$dayrange_from." AND to_ <= ".$dayrange_to." AND uid=".$_POST['uid']."";
	$result2=mysql_query($query2);
	$row2=mysql_fetch_array($result2);
	if ($row2['total']=="") {$row2['total']=0;}
	
	if ($row2['total'] != $row['att']) {
		
		echo "<b>".date('m/d/Y',$row['day']).":</b> ".$loc->attendancefromattendance.": ".$time->tohm($row['att'])." ".$loc->attendancefromworkload.": ".$time->tohm($row2['total'])." <br>";
		}
	}
//echo $query;
*/



for($i=$from;$i<=$to;$i=$i+86400) {
	$dayrange_from=strtotime(date('m/d/Y',$i)." 00:00:01");
	$dayrange_to=strtotime(date('m/d/Y',$i)." 23:59:59");
	//echo $dayrange_from." ".$dayrange_to;	
	$query2="select sum(duration) as total from userjobs where from_ >= ".$dayrange_from." AND to_ <= ".$dayrange_to." AND uid=".$_POST['uid']."";
	$query="select att from attendance where day = ".$i." AND uid=".$_POST['uid']." ORDER BY day";
	$result=mysql_query($query);
	$result2=mysql_query($query2);
	$row2=mysql_fetch_array($result2);
	$row=mysql_fetch_array($result);
	if ($row2['total']=="") {$row2['total']=0;}
	if ($row['att']=="") {$row['att']=0;}
	if ($row2['total'] != $row['att']) {
		
		echo "<b>".date('m/d/Y',$i).":</b> ".$loc->attendancefromattendance.": ".$time->tohm($row['att'])." ".$loc->attendancefromworkload.": ".$time->tohm($row2['total'])." <br>";
		
		}
	//echo $row['att']." ".$row2['total'];
	}


}
?>
